package com.ymatou.iapi.productsynces.testcase;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mongodb.BasicDBObject;
import com.shop2cn.iapi.shenqisettlement.parameter.bean.GetCurrencyConfigBean;
import com.shop2cn.iapi.shenqisettlement.parameter.resp.GetCurrencyConfigResp;
import com.shop2cn.iapi.shenqisettlement.service.GetCurrencyConfigCall;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ImportAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ModifyAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.UpdateStockAndPriceBean;
import com.shop2cn.iapi.agentproducts.service.AddAgentProductCall;
import com.shop2cn.iapi.agentproducts.service.ImportAgentProductCall;
import com.shop2cn.iapi.agentproducts.service.ModifyAgentProductCall;
import com.ymatou.iapi.liveseller.parameter.CreateLiveActivityBean;
import com.ymatou.iapi.liveseller.parameter.CreateSellerLiveBean;
import com.ymatou.iapi.liveseller.parameter.ModifyLiveActivityBean;
import com.ymatou.iapi.liveseller.service.ModifyLiveActivityCall;
import com.ymatou.iapi.prodstock.parameter.AgentProductPo;
import com.ymatou.iapi.prodstock.parameter.AuditProductActivityStockBean;
import com.ymatou.iapi.productmanager.parameter.SaveGrouponBean;
import com.ymatou.iapi.productmanager.parameter.SetPspStatusBean;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.iapi.productmanager.parameter.product.ModifySellerProductRequest;
import com.ymatou.iapi.productmanager.service.ModifySellerProductCall;
import com.ymatou.iapi.productmanager.service.SetPspStatusCall;
import com.ymatou.iapi.productmanager.service.UpdateProductSensitiveWordCall;
import com.ymatou.iapi.productsynces.parameter.ESBean;
import com.ymatou.iapi.productsynces.parameter.ESsearchBean;
import com.ymatou.iapi.productsynces.parameter.es.EsGodProduct;
import com.ymatou.iapi.productsynces.parameter.es.EsProduct;
import com.ymatou.iapi.productsynces.service.ESCall;
import com.ymatou.iapi.productsynces.service.ESGodsearchCall;
import com.ymatou.iapi.productsynces.service.ESsearchCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.*;
import com.ymttest.database.annotation.SqlMapperFactory;
import com.ymttest.database.annotation.product.IntergratedProductMapper;
import com.ymttest.database.model.*;
import com.ymttest.database.sqlwapper.*;
import com.ymttest.utils.*;
import org.apache.http.client.ClientProtocolException;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.*;
import org.junit.experimental.categories.Category;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class Ts_ESsearch {
	
	private static ESBean esBean;
	private static ESCall escall;
	
	private static ESsearchBean bean;
	private static ESsearchCall call;
	private static ESGodsearchCall godCall;
	private static YmtCatalogsWapper ymtCatalogsWapper=new YmtCatalogsWapper();
	
	private static YmtProductActivityStockWapper productActStockWapper=new YmtProductActivityStockWapper();
	private static ModifyLiveActivityBean modifyliveactivityBean=new ModifyLiveActivityBean();
	private static ModifyLiveActivityCall modifyliveactivityCall=new ModifyLiveActivityCall();
	private static int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
	private static int globalSellerId = Integer.parseInt(EnvSetup.getData("globalSellerId"));
	
	private static YmtCatalogsWapper catalogdWapper=new YmtCatalogsWapper();
	private static YmtProductsWapper ymtproductsWapper=new YmtProductsWapper();
	private YmtProductActivityStockWapper ymtProductActivityStockWapper=new YmtProductActivityStockWapper();
	private static YmtProductsInActivityWapper productInActivityWapper=new YmtProductsInActivityWapper();
	private static int sellerId3 = Integer.parseInt(EnvSetup.getData("SellerId"));//3383
	private  YmtProductsIWapper YmtProductsIWapper =new YmtProductsIWapper();
	private static IntergratedProductMapper ipm = SqlMapperFactory
            .getIntergratedProductMapper();
	
	private YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
	private YmtProductCategoryWapper ymtProductCategoryWapper=new YmtProductCategoryWapper();
	private YmtProductBrandWapper ymtProuductBrandWapper=new YmtProductBrandWapper();
	private ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
	private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
    private YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
	
	//渠道商
		private static int sellerId1 = AgentUsers.rootUserId;
		private static String sellerName1 = "NickautoTest";
		//代理商1
		private static int agentUserId1 = AgentUsers.agentUserId1;
		private static String agentUserName1 = "NickautoTest";
		//代理商2
		private static int agentUserId2 = AgentUsers.agentUserId2;
		private static String agentUserName2 = "NickautoTest";
		private static AddAgentProductCall addagentproductCall=new AddAgentProductCall();
		//渠道商->代理商1
		private static int mch_agentUserId1 = AgentUsers.agentUserId1;
		private static String mch_agentUserName1 = "NickautoTest";
		
		//vip渠道
		private static int vipRootUserId = AgentUsers.vipRootUserId;
		private static String vipRootUserName = "NickautoTest";
		//vip渠道->代理
		private static int vipAgentUserId1 = AgentUsers.vipAgentUserId1;
		private static String vipAgentUserName1 = "dgsq408897016";
		//vip渠道->代理->代理
		private static int vipAgentUserId2 = AgentUsers.vipAgentUserId2;
		private static String vipAgentUserName2 = "NickautoTest";
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("同步ES");
	}
	
	@Before
	public void caseUp() {
		bean = new ESsearchBean();
		call = new ESsearchCall();	
		escall=new ESCall();
		esBean=new ESBean();
		godCall=new ESGodsearchCall();
	}
	
	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}
	
	@After
	public void caseDown() {
		Logger.end();
	}
	/**
	 * 校验代理商品
	 * @param product
	 * @param productId 1：若是渠道自采商品 productId指自采商品Id  2：若是代理商品 productId指代理商品Id
	 * @param productId2 如果是代理商品，二级分类来自 渠道自采商品  productId2是渠道自采商品Id
	 * @throws Exception
	 */
	private void checkverify_godProduct(EsGodProduct product,String productId,String... productId2) throws Exception
	{
		//ymt_product 与 es 比较
		AgentProductPo mainAgentProductPo=null;
		 YmtProductsI YmtProductsI =null;
		 YmtProductsI YmtAgentProductsI =null;
		 Integer userId=null;
		 String sProduct=null;
		 Date lastUpdate=new Date();
		 Integer status=0;//1:下架 2:上架
		 String title=null;
		 String remark=null;
		 String productParam=null;
		if(productId2.length>0)
		{
			 YmtProductsI=YmtProductsIWapper.selectProductByProductId(productId2[0]).get(0);
			 YmtAgentProductsI=YmtProductsIWapper.selectProductByProductId(productId).get(0);
			 userId=YmtAgentProductsI.getiUserId();
			 sProduct=YmtAgentProductsI.getsProduct();
			 lastUpdate= YmtAgentProductsI.getdLastUpdate();
			 title=YmtAgentProductsI.getsProduct();
			 remark=YmtAgentProductsI.getRemark();
			 //issellout
			 check_godMainProduct_issellout(productId2[0],product);
		     mainAgentProductPo= YmtProductsIWapper.selectAgentProductByProductId(productId2[0]);   
		    
		}
		else
		{
			 YmtProductsI=YmtProductsIWapper.selectProductByProductId(productId).get(0);
			 userId=YmtProductsI.getiUserId();
			 sProduct=YmtProductsI.getsProduct();
			 lastUpdate= YmtProductsI.getdLastUpdate();
			 title=YmtProductsI.getsProduct();
			 remark=YmtProductsI.getRemark();
			 //issellout
			 check_godMainProduct_issellout(productId,product);
	
		}
//		AgentProductPo agentProductPo=YmtProductsIWapper.selectAgentProductByProductId(productId);
//		productParam=agentProductPo.getProductParam();
		Logger.comment("remark:"+remark);
       //ymt_AgentProducts  与 es 比较
        AgentProductPo agentProductPo= YmtProductsIWapper.selectAgentProductByProductId(productId);
        productParam=agentProductPo.getProductParam().replace(":", " ").replace("{", "").replace("}", "").replace("'", "");
        Map category=null;
        Map category2=null;
        Map category3=null;
        if(YmtProductsI.getiCategoryId()!=0){
        //Ymt_ProductCategory 二级分类
         category= ymtProductCategoryWapper.getGodProductCategoryByCategoryId(YmtProductsI.getiCategoryId()).get(0);
        //一级分类
         category2= ymtProductCategoryWapper.getGodProductCategoryByCategoryId(Integer.parseInt(category.get("iMasterCategory").toString())).get(0);
        }
        if(YmtProductsI.getiThirdCategoryId()!=0){
        //三级分类
         category3= ymtProductCategoryWapper.getGodProductCategoryByCategoryId(YmtProductsI.getiThirdCategoryId()).get(0);
        }
        //品牌
        Map brand=null;
        if(YmtProductsI.getiBrandId()!=0)
          brand= ymtProuductBrandWapper.getProductBrandByBrandId(YmtProductsI.getiBrandId()).get(0);
        
		Logger.verifyEquals(product.getPid(), productId, "验证返回spid");
		
		Logger.verifyEquals(product.getSid(), userId, "验证返回Sid");
		
		//Logger.verifyEquals(product.gettitle(), sProduct, "验证返回sProduct");
		
        Logger.verifyEquals(product.getfcateid(), category==null?0:Integer.parseInt(category.get("iMasterCategory").toString()), "验证es返回一级分类Id  Ymt_ProductCategory.iCategoryId");
        Logger.verifyEquals(product.getScateid(), YmtProductsI.getiCategoryId(), "验证es返回二级分类Id  mt_Products.iCategoryId");
        Logger.verifyEquals(product.getTcateid(), YmtProductsI.getiThirdCategoryId(), "验证es返回三级分类Id  Ymt_Products.iThirdCategoryId");
       
        Logger.verifyEquals(agentProductPo.getAgentType(),product.getatype(), "验证传入的商品类型atype与es数据库是否一致(代理类型，0-自采，1-普通代理，2-VIP代理");
        
        Logger.verifyEquals(mainAgentProductPo!=null?mainAgentProductPo.getStatus():agentProductPo.getStatus(),product.getstatus(), "验证传入的商品类型status与es数据库是否一致代理商品状态（1-上架，2-下架）");
        //infop
		Logger.verifyEquals(product.getinfop(),agentProductPo.getInfoProgress(), "验证返回infop 为0,未改变(信息完善进度，-2-价格问题，-1-信息未完善，0，信息完整)");
	   //utime
	    SimpleDateFormat sdformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Logger.verifyEquals(sdformat.format(product.getutime()),sdformat.format(agentProductPo.getUpdateTime()), "验证传入的商品LastUpdate与es数据库的utime是否一致Ymt_Products.dLastUpdate");
	   //stime
		Logger.verifyNotNull(product.getStime(), "验证返回的es数据库的Stime应用服务器当前时间 不为空");
	   //title title+一级分类+二级分类+三级分类+品牌中文+品牌英文
		//String titleString=title+(category2==null?" ":" "+category2.get("sCategory").toString())+(category==null?" ":" "+category.get("sCategory").toString())+(category3==null?" ":" "+category3.get("sCategory").toString())
		String subTitle=agentProductPo.getSubTitle()==null?"":" "+agentProductPo.getSubTitle();
		String titleStr=title+subTitle+(category3==null?" ":" "+category3.get("sCategory").toString())
		+(brand==null?" ":" "+brand.get("sBrand").toString())+(brand==null?" ":" "+brand.get("sBrandEn").toString())
		+(productParam!=null?(" "+productParam):"");
		Logger.comment("#####  titleString  ########## "+titleStr);
	    Logger.verifyEquals(titleStr.trim(),product.gettitle(), "验证传入的商品类型title与es数据库是否一致 title+一级分类+二级分类+三级分类+品牌中文+品牌英文");
	   
       //计算汇率
	   AgentProductPo agentProduct = ymtProductsIWapper.selectAgentProductByProductId(productId);
       GetCurrencyConfigBean getcurrencyconfigBean=new GetCurrencyConfigBean();
       GetCurrencyConfigCall getcurrencyconfigCall=new GetCurrencyConfigCall();
	   getcurrencyconfigBean.setCurrency(agentProduct.getCurrency());
	   getcurrencyconfigCall.setData(getcurrencyconfigBean);
	   getcurrencyconfigCall.callService();
	   GetCurrencyConfigResp currencyConfigResp = getcurrencyconfigCall
				.getCurrencyConfigResp();
	   //汇率
	   BigDecimal exchangeRmbRate=currencyConfigResp.getExchangeRmbRate();
	   //获取规格的最小价格
	   BigDecimal minPrice=BigDecimal.ZERO;
	   BigDecimal maxPrice=BigDecimal.ZERO;
	   BigDecimal rmbminp=BigDecimal.ZERO;
	   //查询规格列表
	   List<YmtCatalogs> clst =ymtCatalogsWapper.selectCatalogs(productId);
	   maxPrice=clst.stream().max((x,y)->Double.compare(Double.parseDouble(x.getFquoteprice().stripTrailingZeros().toPlainString())
			   ,Double.parseDouble(y.getFquoteprice().stripTrailingZeros().toPlainString()))).get().getFquoteprice();
	   
	   minPrice=clst.stream().min((x,y)->Double.compare(Double.parseDouble(x.getFquoteprice().stripTrailingZeros().toPlainString())
			   ,Double.parseDouble(y.getFquoteprice().stripTrailingZeros().toPlainString()))).get().getFquoteprice();
	   
	   rmbminp=minPrice.multiply(exchangeRmbRate).setScale(2, BigDecimal.ROUND_DOWN);
	   Logger.comment("###############exchangeRmbRate:"+exchangeRmbRate);
	   
	   Logger.verifyEquals(product.getrmbminp().stripTrailingZeros().toPlainString(), rmbminp.stripTrailingZeros().toPlainString(), "验证返回rmbminp");
	   Logger.verifyEquals(product.getminp().stripTrailingZeros().toPlainString(), minPrice.stripTrailingZeros().toPlainString(), "验证返回minPrice");
	   Logger.verifyEquals(product.getmaxp().stripTrailingZeros().toPlainString(), maxPrice.stripTrailingZeros().toPlainString(), "验证返回maxPrice");
	   //币种currency
	   Logger.verifyEquals(product.getCurrency(),agentProduct.getCurrency(), "验证返回Currency");
       //remark
	   Logger.verifyEquals(product.getRemark(),remark, "验证返回Remark");
	   //新增 20200506
	   Logger.verifyEquals(product.getIcs(), YmtProductsI.getiCatalogStatus(), "验证返回ics");
	   Logger.verifyEquals(product.getIba(), YmtProductsI.getiBondedArea(), "验证返回iba");
       //求出所有的规格库存 新增 20200506
	   List<YmtCatalogs> clst2 =ymtCatalogsWapper.selectCatalogs(productId2.length>0?productId2[0]:productId);
	   Integer inum=clst2.stream().mapToInt(a->a.getInum()).sum();
	   Logger.verifyEquals(inum,product.getStock(), "验证返回inum");
	   
	   Logger.comment("product.getIcs():"+product.getIcs());
	   Logger.comment("product.getIba():"+product.getIba());
	   Logger.comment("inum:"+inum);
	   
	   //新增 20200703 后面记得添加验证点 渠道商和代理
	  // Logger.verifyEquals(product.getPsid(), mainAgentProductPo!=null?mainAgentProductPo.getParentUserId():0, "验证返回ParentUserId");


	}
	/**
	 * 验证渠道商品是否售完
	 * @param productId
	 * @throws Exception
	 */
	private void  check_godMainProduct_issellout(String productId,EsGodProduct product) throws Exception
	{
		 //验证是否渠道售完
        int inum=0;//规格上的库存
        BasicDBObject search = new BasicDBObject();
		search.append("spid", productId);
		List<YmtCatalogs> clist =ymtCatalogsWapper.selectCatalogs(productId);
		for(int i=0;i<clist.size();i++)
		{
			inum += clist.get(i).getInum();
		}
		if(inum>0)
			Logger.verifyEquals(false, product.getissellout(), "验证es中的issellout是否售罄");
		else
			Logger.verifyEquals(true, product.getissellout(), "验证es中的issellout是否售罄");

	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_001() {
		Logger.start(true,"同步ES-验证指令SyncLiveActivityProduct,直播商品秒杀活动");
		try{
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() +  1000*60*31);
			//Date starttime = new Date(now.getTime() +  3000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			//starttime = new Date(now.getTime() +  5000);
			starttime = new Date(now.getTime() +  1000*60*33);
			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);
			
			modifyliveactivityBean=LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
			//修改结束时间
			modifyliveactivityBean.getLiveActivity().setEndTime(String.valueOf(new Date(now.getTime() + 201 * 60 * 1000).getTime()));
			//修改价格和库存
			modifyliveactivityCall.setData(modifyliveactivityBean);
			modifyliveactivityCall.callService();
			
			//修改
			//活动Id
			int iActivityID=modifyliveactivityBean.getLiveActivity().getLiveActivityId();
			//商品在活动中的商品Id
			int productInActivityId=modifyliveactivityBean.getLiveActivity().getActivityProducts().get(0).getActivityProductId();
			int transactionId=TestDataManager.getRandomIntNum(5);
			int stockNum=TestDataManager.getRandomIntNum(1);

			Map map=productActStockWapper.selectBy(MapUtil.hashMap("sproductid",productId,"iactivityid",iActivityID));
			int count=productActStockWapper.updateiStockNumByProductActivityStockId(map.get("sProductActivityStockID").toString(),stockNum);
			Logger.comment("stockNum######:"+stockNum);
			//同步es
			esBean.setActivityId(iActivityID);
			esBean.setActionType("SyncLiveActivityProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(transactionId);
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
	        //验证库存stock
		    int sumStock=0;
			List<Map> maps=productActStockWapper.selectAllBy(MapUtil.hashMap("sproductid",productId,"iactivityid",iActivityID));
			for(Map p:maps)
				sumStock=sumStock+Integer.parseInt(p.get("iStockNum").toString());
			
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getActivities().get(0).getStock(), sumStock, "验证es返回的库存");

		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_002() {
		Logger.start(true,"同步ES-验证指令CreateProduct,新增商品");
		try{
			//发布一个活动商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
			//同步es
			esBean.setActionType("CreateProduct");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(9));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
		    //验证商品编号spid
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getPid(), productId, "验证es返回的商品编号productId");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_002_1() {
		Logger.start(true,"同步ES-验证指令CreateProduct,新增商品-全球优选商品");
		try{
			//发布一个活动商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(globalSellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
			//同步es
			esBean.setActionType("CreateProduct");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(9));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
		    //验证商品编号spid
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getPid(), productId, "验证es返回的商品编号productId");
			//ptype=2是全球优选 gtype=1 是大礼包
			Logger.verifyEquals(2, product.getptype(), "验证传入的商品类型ptype与es是否一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_002_2() {
		Logger.start(true,"同步ES-验证指令CreateProduct,新增商品-大礼包");
		try{
			//发布一个活动商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(globalSellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(globalSellerId,productId,1);
		
			Logger.verifyNotNull(productId, "响应报文-商品ID");
			//同步es
			esBean.setActionType("CreateProduct");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(9));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
		    //验证商品编号spid
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getPid(), productId, "验证es返回的商品编号productId");
			//ptype=2是全球优选 gtype=1 是大礼包
            Logger.verifyEquals(2,product.getptype(),
            		"验证传入的商品类型ptype与mongo是否一致");
            Logger.verifyEquals(1,product.getgtype(),
            		"验证传入的商品类型gtype与mongo是否一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_003() {
		Logger.start(true,"同步ES-验证指令ModifyProduct,修改商品");
		try{
			YmtProductsWapper productWapper=new YmtProductsWapper();
			//获取当前时间&结束时间
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			String startTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(0), 0);
			String endTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(7), 0);
			
			//发布一个活动商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");

			Logger.comment("productID1:"+productId);
			YmtProducts products=productWapper.selectProductByProductId(productId);
			//修改 
			String productName="测试mongo同步_"+startTime;
			products.setSproduct("测试mongo同步_"+startTime);
	        int count=productWapper.updateNameByProductId(products.getSproduct(),products.getSproductid());
			Logger.comment("count:"+count);
			
			//同步es
			esBean.setActionType("ModifyProduct");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(9));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
		    //验证商品编号spid
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getPname(), productName, "验证es返回的商品编号productName");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_003_1() {
		Logger.start(true,"同步ES-验证指令ModifyProduct,修改商品-spu商品");
		try{
			
			YmtProductsWapper productWapper=new YmtProductsWapper();
			String startTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(0), 0);
			String endTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(7), 0);
			
			//发布一个活动商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerSpuProduct(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//spu商品编号 sppid
		//	addpro.getProduct().setSpuProductId(TestDataManager.getRandomIntNum(5));
			addpro.getProduct().setSpuId(229);
			addpro.getProduct().setSpuProductId(229);
			
			//spuCatalogId标准商品库规格id spcid
			addpro.getProduct().getCatalogList().get(0).setSpuCatalogId(11);
			//publishType 发布类型 0- 标准商品，1- 图片商品，2- 视频商品 pubtype
			addpro.getProduct().setPublishType(1);
			//ProductTags 选填，商品标签列表 tag 
			addpro.getProduct().setProductTags(Lists.newArrayList("Tags1","Tags2"));
			
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");

			Logger.comment("productID1:"+productId);
			YmtProducts products=productWapper.selectProductByProductId(productId);
			//新增20200521
			//spuCatalogId标准商品库规格id spcid
			addpro.getProduct().getCatalogList().get(0).setSpuCatalogId(22);
			//publishType 发布类型 0- 标准商品，1- 图片商品，2- 视频商品 pubtype
			addpro.getProduct().setPublishType(2);
			//ProductTags 选填，商品标签列表 tag 
			addpro.getProduct().setProductTags(Lists.newArrayList("uTags1","uTags2"));
			
			//addpro.getProduct().setSpuProductId(TestDataManager.getRandomIntNum(5));
			
 			ProductManagerCallServiceV3.ModifySellerProduct(productId,addpro);

			//同步es
			esBean.setActionType("ModifyProduct");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(9));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
		    //验证商品编号spid
			EsProduct product=call.getEsProduct();
			
			Logger.verifyEquals(product.getCs(), 0, "验证是否强制下架");
			Logger.verifyEquals(product.getAs(), 0, "验证审核状态");
			Logger.verifyEquals(product.getSppid(), addpro.getProduct().getSpuProductId(), "验证spu商品编号");
			Logger.verifyEquals(product.getPubtype(), addpro.getProduct().getPublishType(), "验证发布类型 0- 标准商品，1- 图片商品，2- 视频商品 ");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_003_2() {
		Logger.start(true,"同步ES-验证指令ModifyProduct,修改商品-奢侈品、物流");
		try{
			YmtProductsWapper productWapper=new YmtProductsWapper();
			String startTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(0), 0);
			String endTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(7), 0);
			//发布商品
			/*奢侈品
			 * 类目 1001  1002  1003
                                     品牌 10187
                                      价格在1000-99999之间
			 */
			AddSellerProductRequest addpro =ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(3383);
			addpro.getProduct().getCatalogList().get(0).setPrice(10000);
			addpro.getProduct().getCatalogList().get(0).setNewPrice(10000);
			addpro.getProduct().getCatalogList().get(0).setVipPrice(10000);
			addpro.getProduct().getCatalogList().get(0).setMarketPrice(18000);
            //物流时效
			addpro.getProduct().setDeliveryCompanyType(1);
			addpro.getProduct().setDeliveryAging(5);
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			Logger.verifyNotNull(productId, "响应报文-商品ID");

			Logger.comment("productID1:"+productId);
			YmtProducts products=productWapper.selectProductByProductId(productId);
			//修改 
			String productName="测试mongo同步_"+startTime;
			products.setSproduct("测试mongo同步_"+startTime);
	        int count=productWapper.updateNameByProductId(products.getSproduct(),products.getSproductid());
			Logger.comment("count:"+count);
			
			//同步es
			esBean.setActionType("ModifyProduct");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(9));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
		    //验证商品
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getPid(), productId, "验证es返回的商品编号");
			Logger.verifyEquals(product.getDct(), addpro.getProduct().getDeliveryCompanyType(), "验证es返回的Dct1.官方 2.三方");
			Logger.verifyEquals(product.getDa(), addpro.getProduct().getDeliveryAging(), "验证es返回的时效 天 5,10,15");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_ESsearch_004() {
		Logger.start(true,"同步ES-验证指令UpdateLiveTimeForEs,更新扫货线程的商品直播时间");
		try{
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			LiveRoomCallService.UpdateLiveTimeToStart(createlive.getId());
			
		   //获取商品在直播中的Id
			Map map=new LiveRoomWapper().selectLiveproductByLiveid(createlive.getId()).get(0);
			int liveProductId=Integer.parseInt(map.get("LiveProductId").toString());
			Logger.comment("liveProductId："+liveProductId);

			//修改库存stock
			esBean.setActivityId(liveProductId);
			esBean.setActionType("UpdateLiveTimeForEs");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_005() {
		Logger.start(true,"同步ES-验证指令AddProduct,添加商品（批量）");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);

			//修改库存stock
			esBean.setActivityId(0);
			esBean.setActionType("AddProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getPid(), productId, "验证es返回的商品编号");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_005_1() {
		Logger.start(true,"同步ES-验证指令AddProduct,添加商品（批量）-spu商品");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerSpuProduct(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//spu商品编号 sppid
		//	addpro.getProduct().setSpuProductId(TestDataManager.getRandomIntNum(5));
			//spuCatalogId标准商品库规格id spcid
			addpro.getProduct().getCatalogList().get(0).setSpuCatalogId(11);
			//publishType 发布类型 0- 标准商品，1- 图片商品，2- 视频商品 pubtype
			addpro.getProduct().setPublishType(1);
			//ProductTags 选填，商品标签列表 tag 
			addpro.getProduct().setProductTags(Lists.newArrayList("Tags1","Tags2"));
			
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);

			//修改库存stock
			esBean.setActivityId(0);
			esBean.setActionType("AddProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			/*
			 * 新增字段：cs（是否强制下架 Ymt_Products.CheckStatus）
                                     新增字段：as（AuditStatus）
                                     新增字段：sppid（Ymt_Products.SpuProductId）
                                     新增字段：pubtype（Ymt_Products.PublishType）
			 */
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getPid(), productId, "验证es返回的商品编号");
			
			Logger.verifyEquals(product.getCs(), 0, "验证是否强制下架");
			Logger.verifyEquals(product.getAs(), 0, "验证审核状态");
			Logger.verifyEquals(product.getSppid(), addpro.getProduct().getSpuProductId(), "验证spu商品编号");
			Logger.verifyEquals(product.getPubtype(), addpro.getProduct().getPublishType(), "验证发布类型 0- 标准商品，1- 图片商品，2- 视频商品 ");
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_005_2() {
		Logger.start(true,"同步ES-验证指令AddProduct,添加商品（批量）-奢侈品、物流(20201202排查-买手没有当前的物流方式发布权限)");
		try{
			AddSellerProductRequest addProdReq =ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(3383);
			addProdReq.getProduct().getCatalogList().get(0).setPrice(10000);
			addProdReq.getProduct().getCatalogList().get(0).setNewPrice(10000);
			addProdReq.getProduct().getCatalogList().get(0).setVipPrice(10000);
			addProdReq.getProduct().getCatalogList().get(0).setMarketPrice(18000);
            //物流时效
			addProdReq.getProduct().setDeliveryCompanyType(1);
			addProdReq.getProduct().setDeliveryAging(5);
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addProdReq).get("Data").getAsJsonObject().get("ProductId").getAsString();

			//修改库存stock
			esBean.setActivityId(0);
			esBean.setActionType("AddProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getPid(), productId, "验证es返回的商品编号");
			Logger.verifyEquals(product.getDct(), addProdReq.getProduct().getDeliveryCompanyType(), "验证es返回的Dct1.官方 2.三方");
			Logger.verifyEquals(product.getDa(), addProdReq.getProduct().getDeliveryAging(), "验证es返回的时效 天 5,10,15");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_006() {
		Logger.start(true,"同步ES-验证指令BatchSetOnShelf,批量商品上架");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			List<String> productIds=Lists.newArrayList();
			productIds.add(productId);
			ProductManagerCallServiceV2.batchSetProductOnSale(productIds, sellerId);
			
			//修改库存stock
			esBean.setActivityId(0);
			esBean.setActionType("BatchSetOnShelf");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			Date dt = new Date();   
		    SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			EsProduct product=call.getEsProduct();
			 Logger.verifyEquals(true, YMTDateUtil.parseYMDHMSDate(YMTDateUtil.getFromDTSDate(product.getNstime().toString(),""))
			    		.before(YMTDateUtil.parseYMDHMSDate(formatDate.format(dt))), "验证es的newstart");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_007() {
		Logger.start(true,"同步ES-验证指令DeleteProduct,删除商品");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			List<String> productIds=Lists.newArrayList();
			productIds.add(productId);
			ProductManagerCallServiceV2.batchDeleteProducts(productIds, sellerId);
			
			call.setData(bean);
			call.callService();
			
			//修改库存stock
			esBean.setActivityId(0);
			esBean.setActionType("DeleteProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
		//	Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();

		//	EsProduct product=call.getEsProduct();
			Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
			EsProduct esproduct = gson.fromJson(new JSONObject(call.getReturnData()).getJSONObject("hits").toString(),EsProduct.class);
		    Logger.verifyEquals(null,esproduct.getPid(),"验证es没有数据");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_007_1() {
		Logger.start(true,"同步ES-验证指令DeleteProduct,删除商品-渠道商品");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			//获取商品ID
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			
			List<String> productIds=Lists.newArrayList();
			productIds.add(productId);
			ProductManagerCallServiceV2.batchDeleteProducts(productIds, sellerId1);
			
			call.setData(bean);
			call.callService();
			Thread.sleep(5000);
			//修改库存stock
			esBean.setActivityId(0);
			esBean.setActionType("DeleteProduct");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			//验证es
			Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
			JSONArray jsonEsProduct = new JSONObject(godCall.getReturnData()).getJSONObject("hits").getJSONArray("hits");    
    	    Logger.verifyEquals(0,jsonEsProduct.length(), "验证删除时Es为空");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_007_2() {
		Logger.start(true,"同步ES-验证指令DeleteProduct,删除商品-代理商品");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			Thread.sleep(2000);
			//获取商品ID
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);
			
			List<String> productIds=Lists.newArrayList();
			productIds.add(agentProductId);
			ProductManagerCallServiceV2.batchDeleteProducts(productIds, agentUserId1);
			call.setData(bean);
			call.callService();
			
			Thread.sleep(5000);
			//修改库存stock
			esBean.setActivityId(0);
			esBean.setActionType("DeleteProduct");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();
			//验证es
			Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
			JSONArray jsonEsProduct = new JSONObject(godCall.getReturnData()).getJSONObject("hits").getJSONArray("hits");    
    	    Logger.verifyEquals(0,jsonEsProduct.length(), "验证删除时Es为空");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_008() {
		Logger.start(true,"同步ES-验证指令ProductPutout,商品下架");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			List<String> productIds=Lists.newArrayList();
			productIds.add(productId);
			ProductManagerCallServiceV2.batchSetProductOffSale(productIds, sellerId);

			esBean.setActivityId(0);
			esBean.setActionType("BatchSetOnShelf");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			Date dt = new Date();   
		    SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			EsProduct product=call.getEsProduct();
			 Logger.verifyEquals(true, YMTDateUtil.parseYMDHMSDate(YMTDateUtil.getFromDTSDate(product.getNetime().toString(),""))
			    		.before(YMTDateUtil.parseYMDHMSDate(formatDate.format(dt))), "验证es的newend");
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_009() {
		Logger.start(true,"同步ES-验证指令ProductStockChange,修改商品库存和价格");
		try{
			YmtCatalogsWapper catalogdWapper=new YmtCatalogsWapper();
				
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");

			Logger.comment("productID1:"+productId);
			
			YmtCatalogs catalogs=catalogdWapper.selectBySproductId(productId);
			//修改 
			//ProductManagerCallServiceV2.updateProductStockNum(sellerId, productId, catalogs.getScatalogid(), 1);
			catalogs.setFquoteprice(new BigDecimal(500));
			catalogs.setInum(1);
			int count=catalogdWapper.updateByPrimaryKey(catalogs);

			esBean.setActivityId(0);
			esBean.setActionType("ProductStockChange");
			esBean.setProductId(productId);
			esBean.setCatalogId(catalogs.getScatalogid());
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			int sumStock=0;
			sumStock=catalogdWapper.selectCatalogs(productId).stream().mapToInt(YmtCatalogs::getInum).sum();
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(sumStock, product.getStock(), "验证es的Stock");
			//修改 20200628 修改价格
			Logger.verifyEquals(catalogs.getFquoteprice().stripTrailingZeros().toPlainString(),  new BigDecimal(product.getCatalogs().get(0).getPrice()).stripTrailingZeros().toPlainString(), "验证es的price");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_010() {
		Logger.start(true,"同步ES-验证指令UpdateSensitiveWord,更新商品敏感词");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			ModifySellerProductRequest modifySellerProductRequest=ProductManagerCallServiceV2.getModifySellerProductRequestFromAddProductBean(productId, addpro);
			modifySellerProductRequest.getProduct().setProductName("测试商品名称SB");//关键子是SB
			ModifySellerProductCall modifySellerProductCall=new ModifySellerProductCall();
			modifySellerProductCall.setData(modifySellerProductRequest);
			modifySellerProductCall.callService();
			
			new UpdateProductSensitiveWordCall().call(productId, sellerId, 1, "SB");//propertyType（1- 商品名称，2- 商品文描文字部分，3- 规格名称，4-套装名称， 5-买家须知，6-买手介绍）

			esBean.setActivityId(0);
			esBean.setActionType("UpdateSensitiveWord");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals("测试商品名称**", product.getPname(), "验证es的商品名称");
			 
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	

	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_012() {
		Logger.start(true,"同步ES-验证指令CatalogStockChange,交易更新商品规格库存");
		try{
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			YmtCatalogs catalogs=catalogdWapper.selectBySproductId(productId);
			
			int transactionId=TestDataManager.getRandomIntNum(9);
			int stockNum=TestDataManager.getRandomIntNum(1)+1;
			
			catalogs.setInum(stockNum);
			int count=catalogdWapper.updateByPrimaryKey(catalogs);
			
			Logger.comment("productId######:"+productId);
			Logger.comment("Scatalogid######:"+catalogs.getScatalogid());
			Logger.comment("stockNum######:"+stockNum);
			
			esBean.setActionType("CatalogStockChange");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setCatalogId(catalogs.getScatalogid());// 规格Id，目前用于交易（包括活动商品）更新库存
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			int sumStock=0;
			sumStock=catalogdWapper.selectCatalogs(productId).stream().mapToInt(YmtCatalogs::getInum).sum();
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(sumStock, product.getStock(), "验证es的Stock");
			 
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_013() {
		Logger.start(true,"同步ES-验证指令ModifyBrandAndCategory,修改商品分类品牌");
		try{
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			YmtProducts product=ymtproductsWapper.selectProductByProductId(productId);
			product.setIbrandid(100);
			product.setIcategoryid(1003);
			int count=ymtproductsWapper.updateByPrimaryKey(product);
			
			int transactionId=TestDataManager.getRandomIntNum(9);
			
			esBean.setActionType("ModifyBrandAndCategory");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			EsProduct productes=call.getEsProduct();
			Logger.verifyEquals(1002, productes.getMcateid(), "验证es的一级分类id");
			Logger.verifyEquals(1003, productes.getTcateid(), "验证es的三级分类id");
			Logger.verifyEquals(1003, productes.getScateid(), "验证es的二级分类id");
			 
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_014() {
		Logger.start(true,"同步ES-验证指令SetPspStatus,设置psp状态");
		try{
			int sellerId=Integer.valueOf(EnvSetup.getData("productpriceSellerId"));
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			
			IntergratedProductMapper ipm = SqlMapperFactory
                    .getIntergratedProductMapper();
            ipm.insertProductInfo(productId,sellerId);
            
			new YmtProductsIWapper().updatePspStatus(productId, 4);
			
			SetPspStatusBean setpspstatusBean = new SetPspStatusBean();
			SetPspStatusCall setpspstatusCall = new SetPspStatusCall();
			
			setpspstatusBean.setIsPassViolate(true);
			setpspstatusBean.setIsRemovePsp(false);
			setpspstatusBean.setProductId(productId);
			setpspstatusBean.setSellerId(sellerId);
			setpspstatusCall.setData(setpspstatusBean);
			setpspstatusCall.callService();	
			
			int transactionId=TestDataManager.getRandomIntNum(9);
			
			esBean.setActionType("SetPspStatus");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			EsProduct productes=call.getEsProduct();
			Logger.verifyEquals(4, productes.getPspstatus(), "验证es的psp状态");
			 
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_015() {
		Logger.start(true,"同步ES-验证指令SyncActivityProduct,如果是预售商品，缴纳保证金 则同步mongo");
		try{
			AuditProductActivityStockBean activityStockBean = ProdStockCallService.initAuditProductActivityStockBean(sellerId);
            String BeginTime = YMTDateUtil.getBeforeOrNextHour(-1, YMTDateUtil.YMDTHMS_STRING);
            activityStockBean.setBeginTime(BeginTime);
            String EndTime = YMTDateUtil.getBeforeOrNextHour(1, YMTDateUtil.YMDTHMS_STRING);
            activityStockBean.setEndTime(EndTime);
            activityStockBean.setActivityType(2);
          
            for(int i=0;i<activityStockBean.getFBXCatalogLockList().size();i++){
	            activityStockBean.getFBXCatalogLockList().get(i).setEarnest(10);//定金（预售活动必填）
	            activityStockBean.getFBXCatalogLockList().get(i).setEarnestDedution(15);//定金立减（预售活动必填）
	            activityStockBean.getFBXCatalogLockList().get(i).setAction(1);//是否删除 -1： 删除，0： 正常，缴了保证金 ,同步mongo；1：预售,未缴保证金，不同步mongo
            }
            ProdStockCallService.AuditProductActivityStock(activityStockBean);
            
			String productId=activityStockBean.getProductID();
			//修改Ymt_ProductActivityStock 表的 Action=0 缴了保证金，同步mongo
			ymtProductActivityStockWapper.updateiActionByActivityIdAndProductId(0, productId,activityStockBean.getActivityID());

			String startTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(0), 0);
			String productName="修改报名活动名称指令测试_"+startTime;
			new YmtActivityWapper().updateSaleSideName(activityStockBean.getActivityID(),productName);
//			
			YmtProductsInActivity  productsInActivity=productInActivityWapper.selectAllByiActivityId(activityStockBean.getActivityID()).get(0);
			
			Logger.comment("##############productsInActivity.getIproductinactivityid():"+activityStockBean.getProductActivityId());
			
			esBean.setActionType("SyncActivityProduct");
			esBean.setActivityId(productsInActivity.getIproductinactivityid());
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			  //验证库存stock
		    int sumStock=0;
			List<Map> maps=productActStockWapper.selectAllBy(MapUtil.hashMap("sproductid",productId,"iactivityid",activityStockBean.getActivityID()));
			for(Map p:maps)
				sumStock=sumStock+Integer.parseInt(p.get("iStockNum").toString());
			
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getActivities().get(0).getStock(), sumStock, "验证es返回预售的库存");
			//Logger.verifyEquals(product.getActivities().get(0).getAid(), productsInActivity.getIproductinactivityid(), "验证es返回预售的活动Id");
			 
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_016() {
		Logger.start(true,"同步ES-验证指令SyncActivityProduct,如果是预售商品，缴纳保证金则同步，两个规格上的预售价不一样");
		try{
			AuditProductActivityStockBean activityStockBean = ProdStockCallService.initAuditProductActivityStockBean(sellerId);
            String BeginTime = YMTDateUtil.getBeforeOrNextHour(-1, YMTDateUtil.YMDTHMS_STRING);
            activityStockBean.setBeginTime(BeginTime);
            String EndTime = YMTDateUtil.getBeforeOrNextHour(1, YMTDateUtil.YMDTHMS_STRING);
            activityStockBean.setEndTime(EndTime);
            activityStockBean.setActivityType(2);//1:普通 2：预售
          
            activityStockBean.getFBXCatalogLockList().get(0).setEarnest(10);//定金（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(0).setEarnestDedution(15);//定金立减（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(0).setAction(1);//是否删除 -1： 删除，0： 正常，缴了保证金 ,同步mongo；1：预售,未缴保证金，不同步mongo
            
            activityStockBean.getFBXCatalogLockList().get(1).setEarnest(20);//定金（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(1).setEarnestDedution(25);//定金立减（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(1).setAction(1);//是否删除 -1： 删除，0： 正常，缴了保证金 ,同步mongo；1：预售,未缴保证金，不同步mongo
            
            ProdStockCallService.AuditProductActivityStock(activityStockBean);
			String productId=activityStockBean.getProductID();
			//修改Ymt_ProductActivityStock 表的 Action=0 缴了保证金
			ymtProductActivityStockWapper.updateiActionByActivityIdAndProductId(0, productId,activityStockBean.getActivityID());
			String startTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(0), 0);
			String productName="修改报名活动名称指令测试_"+startTime;
			new YmtActivityWapper().updateSaleSideName(activityStockBean.getActivityID(),productName);
				
		
			YmtProductsInActivity  productsInActivity=productInActivityWapper.selectAllByiActivityId(activityStockBean.getActivityID()).get(0);
			Logger.comment("##############productsInActivity.getIproductinactivityid():"+activityStockBean.getProductActivityId());
			
			esBean.setActionType("SyncActivityProduct");
			esBean.setActivityId(productsInActivity.getIproductinactivityid());
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			  //验证库存stock
		    int sumStock=0;
			List<Map> maps=productActStockWapper.selectAllBy(MapUtil.hashMap("sproductid",productId,"iactivityid",activityStockBean.getActivityID()));
			for(Map p:maps)
				sumStock=sumStock+Integer.parseInt(p.get("iStockNum").toString());
			
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getActivities().get(0).getStock(), sumStock, "验证es返回预售的库存");
			//Logger.verifyEquals(product.getActivities().get(0).getAid(), activityStockBean.getActivityID(), "验证es返回预售的活动Id");
			 
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_017() {
		Logger.start(true,"同步ES-验证指令SyncActivityProduct,如果是预售商品，未缴纳保证金则不同步");
		try{
			AuditProductActivityStockBean activityStockBean = ProdStockCallService.initAuditProductActivityStockBean(sellerId);
            String BeginTime = YMTDateUtil.getBeforeOrNextHour(-1, YMTDateUtil.YMDTHMS_STRING);
            activityStockBean.setBeginTime(BeginTime);
            String EndTime = YMTDateUtil.getBeforeOrNextHour(1, YMTDateUtil.YMDTHMS_STRING);
            activityStockBean.setEndTime(EndTime);
            activityStockBean.setActivityType(2);//1:普通 2：预售
          
            activityStockBean.getFBXCatalogLockList().get(0).setEarnest(10);//定金（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(0).setEarnestDedution(15);//定金立减（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(0).setAction(1);//是否删除 -1： 删除，0： 正常，缴了保证金 ,同步mongo；1：预售,未缴保证金，不同步mongo
            
            activityStockBean.getFBXCatalogLockList().get(1).setEarnest(20);//定金（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(1).setEarnestDedution(25);//定金立减（预售活动必填）
            activityStockBean.getFBXCatalogLockList().get(1).setAction(1);//是否删除 -1： 删除，0： 正常，缴了保证金 ,同步mongo；1：预售,未缴保证金，不同步mongo
            
            ProdStockCallService.AuditProductActivityStock(activityStockBean);
			String productId=activityStockBean.getProductID();
			//修改Ymt_ProductActivityStock 表的 Action=0 缴了保证金
		//	ymtProductActivityStockWapper.updateiActionByActivityIdAndProductId(0, productId,activityStockBean.getActivityID());
			String startTime = YMTDateUtil.getBeforeOrNextDayStr(YMTDateUtil.getBeforeOrNextDay(0), 0);
			String productName="修改报名活动名称指令测试_"+startTime;
			new YmtActivityWapper().updateSaleSideName(activityStockBean.getActivityID(),productName);
				
		
			YmtProductsInActivity  productsInActivity=productInActivityWapper.selectAllByiActivityId(activityStockBean.getActivityID()).get(0);
			Logger.comment("##############productsInActivity.getIproductinactivityid():"+activityStockBean.getProductActivityId());
			
			esBean.setActionType("SyncActivityProduct");
			esBean.setActivityId(productsInActivity.getIproductinactivityid());
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			  //验证库存stock
		    int sumStock=0;
			List<Map> maps=productActStockWapper.selectAllBy(MapUtil.hashMap("sproductid",productId,"iactivityid",activityStockBean.getActivityID()));
			for(Map p:maps)
				sumStock=sumStock+Integer.parseInt(p.get("iStockNum").toString());
			
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getActivities().size(), 0, "验证es返回activities 为空");
			 
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_018() {
		Logger.start(true,"同步ES-验证指令CreateGroupon,创建商品拼团");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId3);
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			//创建预售 平团价格  fMarketPrice 码头市场价格，max（规格码头市场价*90%，规格码头市场价-10元）   等出来的指要小于 fQuotePrice
			Double price0=addpro.getProduct().getCatalogList().get(0).getPrice();
			Double price1=addpro.getProduct().getCatalogList().get(1).getPrice();
			Double fprice0=price0 * 0.9d>price0 -10?price0 * 0.9d:price0 -10;
			Double fprice1=price1 * 0.9d>price1 -10?price1 * 0.9d:price1 -10;	
			SaveGrouponBean saveGrouponBean=ProductManagerCallServiceV3.initSaveGrouponBean(sellerId3,productId,fprice0>fprice1?fprice1-1:fprice0-1);
			ProductManagerCallServiceV3.SaveGrouponCall(saveGrouponBean);
			
			esBean.setActionType("CreateGroupon");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			  //验证库存stock
		    int sumStock=0;
			List<GrouponProducts> maps = YmtProductsIWapper.selectGrouponProducts(saveGrouponBean.getProductId(), null, 0);
			
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getgversion(), maps.get(0).getVersion(), "验证es返回gversion字段 与数据库sql一致");
			 
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_019() {
		Logger.start(true,"同步ES-验证指令ModifyGrouponPrice,修改商品规格并团价");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId3);
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			//创建预售 平团价格  fMarketPrice 码头市场价格，max（规格码头市场价*90%，规格码头市场价-10元）   等出来的指要小于 fQuotePrice
			Double price0=addpro.getProduct().getCatalogList().get(0).getPrice();
			Double price1=addpro.getProduct().getCatalogList().get(1).getPrice();
			Double fprice0=price0 * 0.9d>price0 -10?price0 * 0.9d:price0 -10;
			Double fprice1=price1 * 0.9d>price1 -10?price1 * 0.9d:price1 -10;	
			SaveGrouponBean saveGrouponBean=ProductManagerCallServiceV3.initSaveGrouponBean(sellerId3,productId,fprice0>fprice1?fprice1-1:fprice0-1);
			
			ProductManagerCallServiceV3.SaveGrouponCall(saveGrouponBean);
			
			List<GrouponProducts> gp = YmtProductsIWapper.selectGrouponProducts(saveGrouponBean.getProductId(), null, 0);
			saveGrouponBean=ProductManagerCallServiceV3.initSaveGrouponBean(sellerId3,productId,price0-2);
			saveGrouponBean.setOperateType(1);//1:编辑 0:创建
			saveGrouponBean.setGrouponProductId(gp.get(0).getGrouponProductId());
			ProductManagerCallServiceV3.SaveGrouponCall(saveGrouponBean);
			
			esBean.setActionType("ModifyGrouponPrice");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			  //验证库存stock
		    int sumStock=0;
			List<GrouponProducts> maps = YmtProductsIWapper.selectGrouponProducts(saveGrouponBean.getProductId(), null, 0);	
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getgversion(), maps.get(0).getVersion(), "验证es返回gversion字段 与数据库sql一致");
			 
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_020() {
		Logger.start(true,"同步ES-验证指令StopGroupon,停止拼团");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId3);
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			//创建预售 平团价格  fMarketPrice 码头市场价格，max（规格码头市场价*90%，规格码头市场价-10元）   等出来的指要小于 fQuotePrice
			Double price0=addpro.getProduct().getCatalogList().get(0).getPrice();
			Double price1=addpro.getProduct().getCatalogList().get(1).getPrice();
			Double fprice0=price0 * 0.9d>price0 -10?price0 * 0.9d:price0 -10;
			Double fprice1=price1 * 0.9d>price1 -10?price1 * 0.9d:price1 -10;	
			SaveGrouponBean saveGrouponBean=ProductManagerCallServiceV3.initSaveGrouponBean(sellerId3,productId,fprice0>fprice1?fprice1-1:fprice0-1);
			
			ProductManagerCallServiceV3.SaveGrouponCall(saveGrouponBean);
			List<GrouponProducts> gp = YmtProductsIWapper.selectGrouponProducts(saveGrouponBean.getProductId(), null, 0);
			ProductManagerCallServiceV3.StopGroupon(gp.get(0).getGrouponProductId());
			
			esBean.setActionType("StopGroupon"); 
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			  //验证库存stock
		    int sumStock=0;
			List<GrouponProducts> maps = YmtProductsIWapper.selectGrouponProducts(saveGrouponBean.getProductId(), null, 1);	
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getgversion(), 0L, "验证es返回gversion字段 为0");
			 
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_047() {
		Logger.start(true,"同步ES-验证指令SyncAlhProduct,同步安利会");
		try{
			//发布一个商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			addpro.getProduct().setProductType(3);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
			ProductManagerCallServiceV3.BatchAddAlhProduct(addpro.getSellerId(),productId);
			
			Thread.sleep(5000);
			
			esBean.setActionType("SyncAlhProduct");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(9));
			
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(5000);
			
			//查询es渠道
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
		   //验证渠道商品
			EsProduct product=call.getEsProduct();
	        Logger.verifyEquals(true,product.getAlh(),
            		"验证传入的商品类型Alh与ES是否一致");
//		     Logger.verifyEquals(false,product.getismb(),
//	            		"验证传入的商品类型ismb与mongo是否一致");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_49() {
		Logger.start(true,"同步ES-验证指令PromoteInfoSync,同步商品推广（抖音）信息(码头商品)(待确认是否更改过-Promote未同步)");
		try{
			//发布一个活动商品		
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
			//同步es
			String startTime=LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
			String endTime=LocalDateTime.now().plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
			Logger.comment("startTime:############"+startTime);
			Logger.comment("endTime:############"+endTime);
			String extString="{\"startTime\":\""+startTime+"\",\"endTime\":\""+endTime+"\",\"promoterIds\":[1,2]}";
			esBean.setActionType("PromoteInfoSync");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(9));
			esBean.setExtParam(extString);
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
		    //验证商品编号spid
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getPid(), productId, "验证es返回的商品编号productId");
			Logger.verifyEquals(product.getPromote().getStime(), startTime, "验证es返回的推广信息的开始时间startTime");
			Logger.verifyEquals(product.getPromote().getEtime(), endTime, "验证es返回的推广信息的结束时间endTime");
			Logger.verifyEquals(product.getPromote().getPids().get(0).toString(), "1.0", "验证es返回的推广信息的达人id Pid");
			Logger.verifyEquals(product.getPromote().getPids().get(1).toString(), "2.0", "验证es返回的推广信息的达人id Pid");

			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_50() {
		Logger.start(false,"同步ES-验证指令PromoteInfoSync,同步商品推广（抖音）信息(码头活动商品)");
		try{
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			//Date starttime = new Date(now.getTime() +  3000);
			Date starttime = new Date(now.getTime() +  1000*60*31);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
		//	starttime = new Date(now.getTime() +  5000);
			starttime = new Date(now.getTime() +  1000*60*33);
			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);
			
			modifyliveactivityBean=LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
			//修改结束时间
			modifyliveactivityBean.getLiveActivity().setEndTime(String.valueOf(new Date(now.getTime() + 201 * 60 * 1000).getTime()));
			//修改价格和库存
			modifyliveactivityCall.setData(modifyliveactivityBean);
			modifyliveactivityCall.callService();
			
			//修改
			//活动Id
			int iActivityID=modifyliveactivityBean.getLiveActivity().getLiveActivityId();
			//商品在活动中的商品Id
			int productInActivityId=modifyliveactivityBean.getLiveActivity().getActivityProducts().get(0).getActivityProductId();
			int transactionId=TestDataManager.getRandomIntNum(5);
			int stockNum=TestDataManager.getRandomIntNum(1);

			Map map=productActStockWapper.selectBy(MapUtil.hashMap("sproductid",productId,"iactivityid",iActivityID));
			int count=productActStockWapper.updateiStockNumByProductActivityStockId(map.get("sProductActivityStockID").toString(),stockNum);
			Logger.comment("stockNum######:"+stockNum);
			//同步es
			String startTime=LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
			String endTime=LocalDateTime.now().plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
			Logger.comment("startTime:############"+startTime);
			Logger.comment("endTime:############"+endTime);
			String extString="{\"startTime\":\""+startTime+"\",\"endTime\":\""+endTime+"\",\"promoterIds\":[1,2]}";
			esBean.setActionType("PromoteInfoSync");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(9));
			esBean.setExtParam(extString);
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
		    //验证商品编号spid
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getPid(), productId, "验证es返回的商品编号productId");
			Logger.verifyEquals(product.getPromote().getStime(), startTime, "验证es返回的推广信息的开始时间startTime");
			Logger.verifyEquals(product.getPromote().getEtime(), endTime, "验证es返回的推广信息的结束时间endTime");
			Logger.verifyEquals(product.getPromote().getPids().get(0).toString(), "1.0", "验证es返回的推广信息的达人id Pid");
			Logger.verifyEquals(product.getPromote().getPids().get(1).toString(), "2.0", "验证es返回的推广信息的达人id Pid");

		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ESsearch_051() {
		Logger.start(true,"同步ES-验证指令UpdateAuditStatus,修改审核状态");
		try{
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);

			ProductManagerCallServiceV3.UpdateAuditStatus(productId, 1);
			
			//修改库存stock
			esBean.setActivityId(0);
			esBean.setActionType("UpdateAuditStatus");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getAs(), 1, "验证es返回的审核状态=1");
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	

	/**
	 * 创建自采商品
                 导入代理商品
	 * @param productId
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	 private void AddAgentProduct_sync(String productId) throws ClientProtocolException, IOException
	 {
		 esBean.setActionType("AddAgentProduct");
		 esBean.setActivityId(0);
		 esBean.setProductId(productId);
		 esBean.setTransactionId(TestDataManager.getRandomIntNum(9));
		 escall.setData(esBean);
		 escall.callService();
	 }



	 //////////////////////// 忽略case ///////////////////////////////

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_ESsearch_009_1() {
		Logger.start(true,"同步ES-验证指令ProductStockChange,修改神器商品库存和价格");
		try{

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			//addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();

			YmtCatalogs catalogs=catalogdWapper.selectBySproductId(productId);

			//修改
			UpdateStockAndPriceBean UpdateStockAndPriceBean=AddAgentProductCallService.initUpdateStockAndPrice(sellerId1, catalogs.getSsku(), productId);
			UpdateStockAndPriceBean.setSalePrice(500d);
			//UpdateStockAndPriceBean.setVirtualStock(3);
			UpdateStockAndPriceBean.setRealStock(3);
			AddAgentProductCallService.UpdateStockAndPrice(UpdateStockAndPriceBean);

			catalogs=catalogdWapper.selectBySproductId(productId);
			Logger.comment("#######ProductId:###########"+productId);

			esBean.setActivityId(0);
			esBean.setActionType("ProductStockChange");
			esBean.setProductId(productId);
			esBean.setCatalogId(catalogs.getScatalogid());
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();

			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();

//			//验证es
			EsGodProduct product=godCall.getEsProduct();
			// checkverify_godProduct(product,productId);
			int sumStock=0;
			sumStock=catalogdWapper.selectCatalogs(productId).stream().mapToInt(YmtCatalogs::getInum).sum();
			Logger.verifyEquals(sumStock, product.getStock(), "验证es的Stock");
			//修改 20200628 修改价格
			Logger.verifyEquals(500d, product.getCatalogs().get(0).getPrice(), "验证es的price");
			Logger.verifyEquals(500d, product.getminp(), "验证es的minp");

		}catch(Exception e){
			Logger.fail(e);
		}
	}



	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_ESsearch_009_2() {
		Logger.start(true,"同步ES-验证指令ProductStockChange,修改神器商品库存和价格,第二次修改重新获取最小价格");
		try{

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,false);
			//addAgentProductBean.getCatalogList().remove(0);
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			YmtCatalogs catalogs=catalogdWapper.selectBySproductId(productId);
			//修改
			UpdateStockAndPriceBean UpdateStockAndPriceBean=AddAgentProductCallService.initUpdateStockAndPrice(sellerId1, catalogs.getSsku(), productId);
			UpdateStockAndPriceBean.setSalePrice(1000d);
			//UpdateStockAndPriceBean.setVirtualStock(3);
			UpdateStockAndPriceBean.setRealStock(4);
			AddAgentProductCallService.UpdateStockAndPrice(UpdateStockAndPriceBean);

			catalogs=catalogdWapper.selectBySproductId(productId);
			Logger.comment("#######ProductId:###########"+productId);

			esBean.setActivityId(0);
			esBean.setActionType("ProductStockChange");
			esBean.setProductId(productId);
			esBean.setCatalogId(catalogs.getScatalogid());
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();

			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();

			//验证es
			EsGodProduct product=godCall.getEsProduct();
			// checkverify_godProduct(product,productId);
			int sumStock=0;
			sumStock=catalogdWapper.selectCatalogs(productId).stream().mapToInt(YmtCatalogs::getInum).sum();
			Logger.verifyEquals(sumStock, product.getStock(), "验证es的Stock");
			//修改 20200628 修改价格
			Logger.verifyEquals(1000d, product.getCatalogs().get(0).getPrice(), "验证es的price");
			Logger.verifyEquals(new BigDecimal(900), product.getminp(), "验证es的minp");


		}catch(Exception e){
			Logger.fail(e);
		}
	}


	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_ESsearch_011() {
		Logger.start(true,"同步ES-验证指令ActivityStockChange,交易更新商品活动库存 (20201202排查-liveseller站点出问题，周忆在排除)");
		try{
			Logger.comment("创建商品");
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));

			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			CreateLiveActivityBean createliveactivityBean = LiveRoomCallService.initCreateLiveActivityBean(createlive.getId(), cids.get(0), 5d, 6, starttime);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);

			modifyliveactivityBean=LiveRoomCallService.initModifyLiveActivityBean(createliveactivityBean);
			//修改结束时间
			modifyliveactivityBean.getLiveActivity().setEndTime(String.valueOf(new Date(now.getTime() + 201 * 60 * 1000).getTime()));

			modifyliveactivityCall.setData(modifyliveactivityBean);
			modifyliveactivityCall.callService();

			//修改
			int iActivityID=modifyliveactivityBean.getLiveActivity().getLiveActivityId();
			int productInActivityId=modifyliveactivityBean.getLiveActivity().getActivityProducts().get(0).getActivityProductId();
			int transactionId=TestDataManager.getRandomIntNum(9);
			int stockNum=TestDataManager.getRandomIntNum(1);

			Map map=productActStockWapper.selectBy(MapUtil.hashMap("sproductid",productId,"iactivityid",iActivityID));
			int count=productActStockWapper.updateiStockNumByProductActivityStockId(map.get("sProductActivityStockID").toString(),stockNum);
			Logger.comment("stockNum######:"+stockNum);

			esBean.setActionType("ActivityStockChange");
			esBean.setActivityId(productInActivityId);
			esBean.setProductId(productId);
			esBean.setCatalogId(map.get("sCatalogID").toString());// 规格Id，目前用于交易（包括活动商品）更新库存
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(10000);
			//查询es
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();

			//验证库存stock
			int sumStock=0;
			List<Map> maps=productActStockWapper.selectAllBy(MapUtil.hashMap("sproductid",productId,"iactivityid",iActivityID));
			for(Map p:maps)
				sumStock=sumStock+Integer.parseInt(p.get("iStockNum").toString());

			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(product.getActivities().get(0).getStock(), sumStock, "验证es返回的库存");

		}catch(Exception e){
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_ESsearch_046() {
		Logger.start(true,"同步ES-验证指令SetMemberProduct,设置/取消  优选会员商品-设置");
		try{
			//发布一个活动商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(globalSellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
			Thread.sleep(5000);

			ProductManagerCallServiceV3.SetMemberProduct(productId, globalSellerId, true);

			Thread.sleep(5000);

			esBean.setActionType("SetMemberProduct");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(9));

			escall.setData(esBean);
			escall.callService();
			Thread.sleep(5000);

			//查询es渠道
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			//验证渠道商品
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(2,product.getptype(),
					"验证传入的商品类型ptype与ES是否一致");
			Logger.verifyEquals(true,product.getismb(),
					"验证传入的商品类型ismb与ES是否一致");

		}catch(Exception e){
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_ESsearch_046_1() {
		Logger.start(true,"同步ES-验证指令SetMemberProduct,设置/取消  优选会员商品-取消");
		try{
			//发布一个活动商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(globalSellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Logger.verifyNotNull(productId, "响应报文-商品ID");
			Thread.sleep(5000);

			ProductManagerCallServiceV3.SetMemberProduct(productId, globalSellerId, false);

			Thread.sleep(5000);

			esBean.setActionType("SetMemberProduct");
			esBean.setActivityId(0);
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(9));

			escall.setData(esBean);
			escall.callService();
			Thread.sleep(5000);

			//查询es渠道
			bean.setProductId("pid:"+productId);
			call.setData(bean);
			call.callService();
			//验证渠道商品
			EsProduct product=call.getEsProduct();
			Logger.verifyEquals(2,product.getptype(),
					"验证传入的商品类型ptype与ES是否一致");
			Logger.verifyEquals(false,product.getismb(),
					"验证传入的商品类型ismb与ES是否一致");

		}catch(Exception e){
			Logger.fail(e);
		}
	}


	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_ESsearch_48() {
		Logger.start(true,"同步ES-验证指令ModifySingleAgentProductSellPrice,修改单个代理商品销售价,修改自采商品,导入代理商品-普通代理");
		try{
			//修改币种sqlserver不变，es改变
			ImportAgentProductCall importagentproductCall=new ImportAgentProductCall();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId1,false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();

			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			Logger.comment("#######agentProductId:###########"+agentProductId);

			//修改
			//ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBeanByImportant(agentProductId,importAgentProductBean);
			ModifyAgentProductBean modifyAgentProductBean=AddAgentProductCallService.initModifyAgentProductBean(productId,addAgentProductBean);
			modifyAgentProductBean.setCurrency("CNY");
			//20200703 修改上级售价
			modifyAgentProductBean.getCatalogList().get(0).setDirectPrice(1500);

			ModifyAgentProductCall modifyAgentProductCall=new ModifyAgentProductCall();
			modifyAgentProductCall.setData(modifyAgentProductBean);
			modifyAgentProductCall.callService();
			Logger.comment("#######ProductId:###########"+agentProductId);

			esBean.setActivityId(0);
			esBean.setActionType("ModifyAgentProduct");
			esBean.setProductId(agentProductId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(10));

			escall.setData(esBean);
			escall.callService();

			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+agentProductId);
			godCall.setData(bean);
			godCall.callService();

//			//验证es
			EsGodProduct product=godCall.getEsProduct();

//            checkverify_godProduct(product,agentProductId,productId);
//            Logger.verifyEquals(product.getisshow(), true, "验证返回isshow");

			//为什么金额和币种 验证要写固定，因为修改渠道商品币种，sql数据库中的代理商品币种没有更改，es中修改了，上面的公共方法算金额，是从数据库中查询的币种，然后查汇率算金额
			Logger.verifyEquals(product.getrmbminp().stripTrailingZeros().toPlainString(),"6990.4", "验证返回rmbminp");
			Logger.verifyEquals(product.getminp().stripTrailingZeros().toPlainString(), "6990.4", "验证返回minPrice");
			Logger.verifyEquals(product.getmaxp().stripTrailingZeros().toPlainString(), "6990.4", "验证返回maxPrice");
			//币种currency
			Logger.verifyEquals(product.getCurrency(),"CNY", "验证返回Currency");

		}catch(Exception e){
			Logger.fail(e);
		}
	}


	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_ESsearch_053() {
		Logger.start(true,"同步ES-验证指令UpdateShowStatus,更新商品露出状态-visible=false");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			addAgentProductBean.getCatalogList().remove(0);
			addAgentProductBean.getCatalogList().get(0).setMarketAmount(10);//神器市场价 新增 20200325
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//更新商品露出状态
			//visible sql中是是否可见，mongo和es 表示意思是是否隐藏，所以sql与mongo意思相反，值也相反
			AddAgentProductCallService.SetVisible(sellerId1, Lists.newArrayList(productId), false);

			esBean.setActivityId(0);
			esBean.setActionType("UpdateShowStatus");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			EsGodProduct product = godCall.getEsProduct();
			Logger.verifyEquals(product.getisshow(), false, "验证es返回的isshow=false");

		}catch(Exception e){
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_ESsearch_053_1() {
		Logger.start(true,"同步ES-验证指令UpdateShowStatus,更新商品露出状态-visible=true");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId1,sellerName1,true);
			addAgentProductBean.getCatalogList().remove(0);
			addAgentProductBean.getCatalogList().get(0).setMarketAmount(10);//神器市场价 新增 20200325
			addagentproductCall.setData(addAgentProductBean);
			addagentproductCall.callService();
			String productId = addagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			//更新商品露出状态
			//visible sql中是是否可见，mongo和es 表示意思是是否隐藏，所以sql与mongo意思相反，值也相反
			AddAgentProductCallService.SetVisible(sellerId1, Lists.newArrayList(productId), true);

			esBean.setActivityId(0);
			esBean.setActionType("UpdateShowStatus");
			esBean.setProductId(productId);
			esBean.setTransactionId(TestDataManager.getRandomIntNum(5));
			escall.setData(esBean);
			escall.callService();
			Thread.sleep(5000);
			//查询es
			bean.setProductId("pid:"+productId);
			godCall.setData(bean);
			godCall.callService();
			EsGodProduct product = godCall.getEsProduct();
			Logger.verifyEquals(product.getisshow(), true, "验证es返回的isshow=true");

		}catch(Exception e){
			Logger.fail(e);
		}
	}
}

